Kinetis SDK Demo Applications User Guide  1.0.0-beta
Freescale Semiconductor, Inc.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
playsound.c File Reference
#include <string.h>
#include "playsound.h"

Functions

static void I2S_SendWavData (uint8_t *DataBuffer, uint32_t len)
 Send I2S data. More...
 
static void snd_card_config (void)
 Initialize the structure information for sai. More...
 
void PLAYSOUND_Init (void)
 Init sound card. More...
 
int PLAYSOUND_Play (APP_GET_DATA_FUNC fpAppGetData)
 Use sound card to play audio, need wave file data, only support standard Windows PCM uncompressed file. More...
 
int PLAYSOUND_GetWaveFileInfo (uint8_t *pBuffer, wave_file_t *pWave)
 Decode wave file header, only support standard Windows PCM uncompressed file. More...
 

Variables

sound_card_t g_card
 
static sai_data_format_t format
 
static sai_user_config_t tx_config
 
static sai_handler_t tx_handler
 
static sgtl_handler_t codec_handler
 

Function Documentation

static void I2S_SendWavData ( uint8_t *  DataBuffer,
uint32_t  len 
)
static

This function should call PD layer funcion snd_trigger_tx.

Parameters
DataBufferpointer for data buffer
lennumber of bytes to write
pformatpointer to a wave data format struct
int PLAYSOUND_GetWaveFileInfo ( uint8_t *  pBuffer,
wave_file_t pWave 
)

This function decode Windows PCM wave file data and, if success, loaded file header information into struct instance.

Parameters
[in]pBufferPointer to a wave file start address.
[in]pWavePointer to a wave_file struct.
Returns
0:succ 1:fail
void PLAYSOUND_Init ( void  )

This function will initialize controller(K70's sai moudle) and decoder(SGTL5000) and config them with default values for play audio.

Note
8 bit is not supported in SGTL5000
int PLAYSOUND_Play ( APP_GET_DATA_FUNC  fpAppGetData)

Before calling this function, we must make sure PLAYSOUND_Init has alrady called. This function will play audio according to wave file data which acquired by a user callback function. Prototyoe of "GetData" function: uint32_t APP_GetData(uint32_t NumBtytesReq, uint8_t **ppData, uint32_t offset)

Parameters
[in]fpAppGetDataPointer to a function which is called by PLAYSOUND_Play routine for getting data.
Returns
0:succ 1:fail
static void snd_card_config ( void  )
static

Variable Documentation

sgtl_handler_t codec_handler
static
sai_data_format_t format
static
sound_card_t g_card
sai_user_config_t tx_config
static
sai_handler_t tx_handler
static